include<BOSL2/std.scad>
include<tools/util.scad>
$fn=100;

//pan();
//translate([100,100,0])leg();

//translate([-100,20,0])t_rod();
//translate([-100,60,0])jinsuo();
//translate([-140,20,0])link_base_mid();

//translate([100,-80,0])phone_link();
//translate([100,-120,0])rod_end();
//translate([100,-160,0])rod_mid();

elbow();

module pan(){
    cylinder(h=14,d=40);
    translate([0,0,14])difference(){
        cylinder(h=60,d=26);
        cylinder(h=60,d=20);
        translate([0,0,30])cylinder(h=31,d=23.2);
    }
    for(ang=[0:120:240]){
        rotate([0,0,ang])translate([0,40,7])difference(){
            cube([10,50,14],center=true);
            translate([0,20.1,0])cube([6.4,30,10.4],center=true);
        }
    }
}

module leg(){
    translate([0,-6,0])difference(){
        leg_points = [[0, 0],[40, 60], [70, 130], [180, 130] ];
        path_sweep(square([10,6]), bezpath_curve(leg_points));
         translate([-10,0,0])cube([20,6,10]);
    }

}


//伸缩控制接头
module t_rod(){
    difference(){
        union(){
            cylinder(h=60,d=26);
            translate([11,-6,45])cube([12,12,15]);
        }
        //倒圆
        translate([22,-5,45])rotate([0,0,-90])d_round_line_mask(r=1,length=15);
        translate([22,5,45])d_round_line_mask(r=1,length=15);
        //挖洞
        translate([12,-4.7,47])cube([9.4,9.4,13.1]);
        translate([8,-3,47])cube([5,6,13.1]);
        translate([20,0,53])rotate([0,90,0])cylinder(h=5,d=5.2);
        
        
        cylinder(h=30,d=23.2);
        translate([0,0,30])cylinder(h=30.1,d=20);
    }
    
    
}
//伸缩滑块
module jinsuo(){
    difference(){
        union(){
            cube([6,9,12.9]);
            translate([6,1.7,0])cube([5,5.6,12.9]);
        }
        translate([0,4.5,6])rotate([0,90,0])d_six_side_cube(edge=4.55,height=4.4);
        translate([19.5,4.5,0])cylinder(h=13,d=19);
    }
}

module link_base_mid(){
    difference(){
        union(){
            cylinder(h=30,d=23);
            translate([0,0,30])cylinder(h=60,d=26);
            translate([0,0,90])cylinder(h=30,d=23);
        }
            
      cylinder(h=120.1,d=20);

    }
    
}

//手机接头，外径19,内径15，公头16.9，母头17.1
module phone_link(){
    difference(){
        union(){
            cylinder(h=30,d=19);
            translate([0,0,30])cylinder(h=30,d=16.9);
            translate([8,0,8.4])rotate([0,90,0])cylinder(h=30,d1=9,d2=7.7);
            translate([34,0,8.4])sphere(8.4);
        }
        translate([0,0,10])cylinder(h=51,d=15);
    }
}

module rod_end(){
    difference(){
        cylinder(h=90,d=19);
        translate([0,0,2])cylinder(h=90,d=15);
        translate([0,0,60])cylinder(h=30.1,d=17.1);
    }
}
module rod_mid(){
       difference(){
        union(){
            cylinder(h=30,d=16.9);
            translate([0,0,30])cylinder(h=90,d=19);
            //translate([0,0,90])cylinder(h=30,d=16.9);
        }
            
      cylinder(h=120.1,d=15);
        translate([0,0,90])cylinder(h=30.1,d=17.1);

    }
}

module elbow(){
    sphere(9.5);
    cylinder(h=30,d=19);
    translate([0,0,30])cylinder(h=30,d=16.9);
    rotate([0,90,0])difference(){
        cylinder(h=90,d=19);
        translate([0,0,60])cylinder(h=30.1,d=17.1);
    }
}